﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TA.Turbo.Controls;

namespace TA.Turbo.Design
{
	/// <summary>
	/// Provides an interface to retrieve the list of validation groups which are used page-wide.
	/// </summary>
	public class ValidationGroupLister : BaseValidationGroupLister
	{
		/// <summary>
		/// Returns the list of validation groups which are used page-wide.
		/// </summary>
		/// <param name="startingPoint"></param>
		/// <returns></returns>
		public override string[] GetValidationGroupList(System.Web.UI.Control startingPoint)
		{
			List<string> valGroups = new List<string>();

			startingPoint.Page.ForEachRecursive<BaseValidator>(delegate(BaseValidator v)
			{
				if (!string.IsNullOrEmpty(v.Group) && !valGroups.Contains(v.Group))
					valGroups.Add(v.Group);
			});

			return valGroups.ToArray();
		}
	}
}
